After receiving a packet that needs to be forwarded, a gateway device needs to encapsulate the packet and then forwards the encapsulated packet. A packet encapsulation operation includes searching, using a routing prefix table and according to a destination Internet Protocol (IP) address of the packet, for an available next hop table, and then encapsulating a source Media Access Control (MAC) address, a destination MAC address, and next hop interface information for the packet using the next hop table.
The next hop table in the gateway device is used to encapsulate a designated destination MAC address for the packet, that is, to process a packet that carries a destination IP address corresponding to the designated destination MAC address. Therefore, when the gateway device is connected to multiple hosts, a corresponding number of next hop tables are required to implement packet encapsulation and forwarding.
A capacity for a next hop table to process packets at the same time is limited, and when the number of packets that carry a destination IP address corresponding to a designated destination MAC address and need to be processed by a gateway device exceeds a capacity of a next hop table used to encapsulate the designated destination MAC address, an excess part of packets cannot be encapsulated because of overflowing next hop table, thereby resulting in a forwarding failure. A method in the prior art leads to poor packet forwarding reliability and a low processing capability of the gateway device.